package io.renren.modules.PCguanli.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.renren.modules.PCguanli.entity.DriversDatcherEntity;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.PCguanli.dao.ResidentPersonnelDao;
import io.renren.modules.PCguanli.entity.ResidentPersonnelEntity;
import io.renren.modules.PCguanli.service.ResidentPersonnelService;


@Service("residentPersonnelService")
public class ResidentPersonnelServiceImpl extends ServiceImpl<ResidentPersonnelDao, ResidentPersonnelEntity> implements ResidentPersonnelService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String key=(String) params.get("key");
        LambdaQueryWrapper<ResidentPersonnelEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(StringUtils.isNotEmpty(key), ResidentPersonnelEntity::getName, key)
                .or().like(StringUtils.isNotEmpty(key), ResidentPersonnelEntity::getId, key)
                .or().like(StringUtils.isNotEmpty(key), ResidentPersonnelEntity::getUserId, key)
                .or().like(StringUtils.isNotEmpty(key), ResidentPersonnelEntity::getIphone, key)
                .or().like(StringUtils.isNotEmpty(key), ResidentPersonnelEntity::getCardealer, key);
        IPage<ResidentPersonnelEntity> page = this.page(
                new Query<ResidentPersonnelEntity>().getPage(params),
                queryWrapper
        );
        return new PageUtils(page);
    }

}